package com.betterjr.modules.accountSupervision.service;

import com.betterjr.common.service.BaseService;
import com.betterjr.mapper.pagehelper.Page;
import com.betterjr.modules.accountSupervision.dao.ScfExceptionMapper;
import com.betterjr.modules.accountSupervision.dao.ScfWarnMapper;
import com.betterjr.modules.accountSupervision.entity.ScfExceptionBean;
import com.betterjr.modules.accountSupervision.entity.ScfWarnBean;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 异常事件
 */
@Service
public class ScfExceptionService extends BaseService<ScfExceptionMapper, ScfExceptionBean> {
    /**
     * 异常事件(异常交易)
     * @param anMap
     * @param anPageNum
     * @param anPageSize
     * @return
     */
    public Page<ScfExceptionBean> queryExceptionWarnList(Map<String, Object> anMap, final int anPageNum, final int anPageSize){
        Page<ScfExceptionBean> page = new Page<>();
        Map<String,Object> map = this.mapper.getExceptionCount(anMap);
        Long count = (Long) map.get("num");
        int start = (anPageNum-1)*anPageSize;
        anMap.put("start",start);
        anMap.put("anPageSize",anPageSize);
        page = Page.listToPage(this.mapper.getExceptionList(anMap));
        page.setPageNum(anPageNum);
        page.setPageSize(anPageSize);
        page.setTotal(count);
        return page;
    }

    public int addExceptionWarn(Map<String, Object> anMap){
        return this.mapper.addException(anMap);
    }

    /**
     * 异常事件(异常交易)数量
     * @return
     */
    public int queryExceptionWarnCount(Map<String, Object> anMap){
        int count = 0 ;
        Map<String,Object> map = this.mapper.getExceptionCount(anMap);
        count = ((Long) map.get("num")).intValue();
        return  count;
    }

}
